home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-ietf-appleip-kip-gateway-00.txt < prev    next >
Text File  |  1993-07-08  |  80KB  |  2,242 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8. DRAFT                                                       Philip Budne
  9.                                                        Shiva Corporation
  10.                                                                July 1993
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                  KIP AppleTalk/IP Gateway Functionality
  17.  
  18.                            $Revision: 1.33 $
  19.                               July 6, 1993
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. 1.  Status of this Memo
  28.  
  29.    This DRAFT documents the functionality of the Stanford ``KIP''
  30.    AppleTalk/IP ``Gateway'' (also called the ``SEAGate code'', ``IP-
  31.    Ether/AppleTalk Gateway'', or ``Croft Gateway'').
  32.  
  33.    This draft document will be submitted to the RFC editor as an
  34.    Informational Document.
  35.  
  36.    This document is an Internet Draft.  Internet Drafts are working
  37.    documents of the Internet Engineering Task Force (IETF), its Areas,
  38.    and its Working Groups. Note that other groups may also distribute
  39.    working documents as Internet Drafts.
  40.  
  41.    Internet Drafts are draft documents valid for a maximum of six
  42.    months. Internet Drafts may be updated, replaced, or obsoleted by
  43.    other documents at any time.  It is not appropriate to use Internet
  44.    Drafts as reference material or to cite them other than as a
  45.    ``working draft'' or ``work in progress''.
  46.  
  47.    Please check the I-D abstract listing contained in each Internet
  48.    Draft directory to learn the current status of this or any other
  49.    Internet Draft.
  50.  
  51.    This document expires December 31, 1993.  Distribution of this memo
  52.    is unlimited.
  53.  
  54.    This memo was started as an effort to describe ``IPTalk'' for the
  55.    AppleTalk-IP Working Group of the Internet Engineering Task Force
  56.    (IETF).  It became apparent that since no protocol standard or
  57.  
  58. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  59.  
  60.  
  61.    description existed that implementation specific information was
  62.    unavoidable. KIP is the prototypical AppleTalk/IP Gateway
  63.    implementation and is available in source form.  KIP's functionality
  64.    forms the basis for many commercial products available today.
  65.  
  66. 2.  History
  67.  
  68.    Following the introduction of the Macintosh computer in 1984, Apple
  69.    donated many units to universities where Ethernet and TCP/IP were the
  70.    primary networking technologies.  The Macintosh had clear advantages
  71.    for text processing applications, including an easy to use user
  72.    interface, bit-mapped display, and a built-in network adaptor for the
  73.    sharing of laser printers.  However, it was equally clear that the
  74.    absence of connectivity to existing large computing systems was a
  75.    serious limitation. Work began at several large universities (notably
  76.    Dartmouth, Stanford and CMU) to provide gateways and client software.
  77.  
  78.    The original ``Stanford Ethernet Applebus Gateway'' was created at
  79.    Stanford University in 1985 by Bill Croft and was known as the
  80.    ``SEAGate''.  The hardware consisted of off-the-shelf Multibus
  81.    components; a ``SUN 1'' 68000 CPU card, an Interlan NI3210 Ethernet
  82.    card, and a simple homebrew Zilog 8530 SCC based ``AppleBus''
  83.    interface.  The SEAGate source code and hardware documents were
  84.    freely available to members of the Internet community.  The initial
  85.    version provided simple transport of encapsulated IP datagrams from
  86.    AppleTalk-based Macintosh computers to Ethernet based IP hosts. Later
  87.    versions added encapsulation of AppleTalk in IP and full AppleTalk
  88.    routing capabilities.  The SEAGate was configured by editing include
  89.    files compiled into the gateway code, and was downloaded over a
  90.    serial port on the CPU card.
  91.  
  92.    The Kinetics FastPath was created using this technology in mid-1985
  93.    and consisted of a 10Mhz 68008 with 48K of battery backed SRAM, an
  94.    i82586 and a Zilog 8530 SCC. A PROM provided for download over
  95.    LocalTalk and a library of buffer management and LocalTalk I/O
  96.    routines for use by the downloaded application.
  97.  
  98.    The SEAGate code was ported to the FastPath and continued to evolve,
  99.    and was renamed ``KIP'' for the ``Kinetics IP'' Gateway.  The name
  100.    ``KIP'' is used in this document only in reference to the gateway
  101.    software.  Unless otherwise noted, all descriptions refer to the June
  102.    1988 (06/88) release of KIP.
  103.  
  104. 3.  Terminology
  105.  
  106.    The KIP ``Gateway'' implements protocols for encapsulation of IP
  107.    datagrams [RFC-791] in DDP for transmission over AppleTalk [Sidhu90]
  108.    internets (IP in DDP), and encapsulation of DDP datagrams in UDP
  109.  
  110.  
  111.  
  112. Budne                  Expires December 31, 1993                [Page 2]
  113.  
  114. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  115.  
  116.  
  117.    [RFC-768] for transmission over IP internets (DDP in UDP).  Both have
  118.    been called ``KIP'' encapsulation; IP in DDP (herein called DDP/IP)
  119.    has also been called ``Dartmouth encapsulation'', ``MacIP'' and
  120.    ``Croft encapsulation'' while DDP in UDP (herein called UDP/DDP) has
  121.    been called ``UDPTalk'', ``IPTalk'', ``AppleTalk in IP'', ``AppleTalk
  122.    over UDP'', and ``IP tunneling''.  KIP can speak both EtherTalk Phase
  123.    1 and UDP/DDP on Ethernet.  This capability has been called
  124.    ``doubletalk''.
  125.  
  126.    The primary existing UDP/DDP host implementation of AppleTalk is the
  127.    Columbia AppleTalk Package (CAP) for Un*x systems.  All references to
  128.    CAP are for Columbia Version 5.0 (using abkip.c).
  129.  
  130.    The KIP sources use the historical terms ``AppleBus'' and
  131.    ``AppleTalk'' in reference to the ``LocalTalk'' physical medium, as
  132.    KIP pre-dates the introduction EtherTalk (and thus the use of the
  133.    name AppleTalk for the protocol family rather than the medium).  The
  134.    term ``Kbox'' is used here to refer to a FastPath running KIP (or any
  135.    functionally similar hardware and software).
  136.  
  137.    All constants are in decimal unless otherwise noted.
  138.  
  139.    The following ``C'' type definitions apply to all data structures and
  140.    code:
  141.  
  142.        typedef unsigned char   u_char;   /*  8 bit ordinal */
  143.        typedef unsigned short  u_short;  /* 16 bit ordinal */
  144.        typedef unsigned long   u_long;   /* 32 bit ordinal */
  145.        typedef long iaddr_t;             /* internet address */
  146.  
  147.  
  148. 4.  UDP/DDP encapsulation
  149.  
  150.    This section describes the algorithms and data structures used by KIP
  151.    to implement UDP/DDP encapsulation.
  152.  
  153. 4.1.  Motivation
  154.  
  155.    UDP/DDP encapsulation was developed before Apple established a
  156.    standard method for the transmission of AppleTalk over Ethernet.  One
  157.    of the primary strengths (and weaknesses) of UDP/DDP is that it uses
  158.    static, centrally administered routing information for the UDP/DDP
  159.    backbone, eliminating the background chatter generated by RTMP and
  160.    ZIP.  In addition one gains the ability to use the large
  161.    infrastructure of existing IP internets to transport AppleTalk over
  162.    long distances.
  163.  
  164.  
  165.  
  166.  
  167.  
  168. Budne                  Expires December 31, 1993                [Page 3]
  169.  
  170. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  171.  
  172.  
  173.    IP networks on which UDP/DDP routers and endnodes are homed are
  174.    assigned AppleTalk network numbers.  This distinguishes UDP/DDP from
  175.    a strict point-to-point ``tunneling'' model in that endnodes can be
  176.    implemented and it allows complete interconnectivity between routers
  177.    without a quadratic number of links.
  178.  
  179.    Because of the static nature of UDP/DDP routes, partial (non-
  180.    transitive) network connectivity can be engineered (ie; A can see B
  181.    and C, but B and C cannot see each other).
  182.  
  183. 4.2.  UDP/DDP network numbers
  184.  
  185.    KIP and CAP configuration files usually represent AppleTalk network
  186.    numbers as a dotted pair of decimal octets, thus network 258 is
  187.    represented as 1.2.  AppleTalk network numbers for UDP/DDP networks
  188.    are chosen manually, and are arbitrary; In fact, KIP does not learn
  189.    from ``seed'' routers at all, and all AppleTalk port network numbers
  190.    must be manually configured.  Each IP network which is to contain
  191.    UDP/DDP hosts (ie; CAP clients and servers) must be assigned a
  192.    UDP/DDP AppleTalk network number.
  193.  
  194.    A common convention for the representation of 8 bit subnets of a
  195.    class B network is to put the subnet number in the low octet and an
  196.    arbitrary constant in the top octet.  If the subnet is also used for
  197.    EtherTalk a different high octet is used.
  198.  
  199.                  IP subnet     UDP/DDP net   EtherTalk net
  200.                  _________________________________________
  201.                  129.2.50.0    55.50         57.50
  202.                  129.2.100.0   55.100        57.100
  203.                  129.2.200.0   55.200        57.200
  204.  
  205.  
  206.    As on any Phase 1 network, there can only be 254 hosts on a UDP/DDP
  207.    network.  Only the first 254 hosts (low octet equal to 1 through 254)
  208.    of a network with more than 8 bits of host number are eligible to
  209.    participate in UDP/DDP.
  210.  
  211.    IP (sub-)networks with more than 254 hosts can be represented as
  212.    several UDP/DDP networks at the cost of redundant NBP lookup
  213.    broadcast traffic.
  214.  
  215. 4.3.  UDP/DDP Node numbers
  216.  
  217.    Each CAP UDP/DDP host must be associated with one UDP/DDP network
  218.    (even if the underlying IP host is multi-homed).  The AppleTalk node
  219.    number of a UDP/DDP host is always the low order octet of the host's
  220.    IP address on the connected UDP/DDP network.
  221.  
  222.  
  223.  
  224. Budne                  Expires December 31, 1993                [Page 4]
  225.  
  226. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  227.  
  228.  
  229. 4.4.  UDP/DDP Address resolution
  230.  
  231.    Since UDP/DDP encapsulation converts AppleTalk addresses to IP
  232.    addresses algorithmicly, no additional Address Resolution Protocol is
  233.    required.
  234.  
  235. 4.5.  UDP/DDP packet format
  236.  
  237.    UDP/DDP packets are encapsulated in UDP with the IP destination
  238.    address and UDP source and destination ports calculated based on
  239.    route type (see next section).
  240.  
  241.    Each UDP/DDP packet contains a dummy three byte LAP header
  242.    (destination, source and type) the same as LocalTalk and EtherTalk
  243.    Phase 1. This has the helpful effect of assuring alignment of the
  244.    encapsulated data (otherwise the DDP header would cause odd
  245.    alignment). UDP/DDP packets output by KIP always have a LAP
  246.    destination of 250 and a LAP source of 206 (which spells ``FACE'' in
  247.    a hex dump).
  248.  
  249.    Packets originated by CAP have the source and final destination nodes
  250.    numbers equal to the DDP source and destination node (regardless of
  251.    the destination network)!!  KIP and CAP only send packets of LAP type
  252.    2 (long DDP).
  253.  
  254.    KIP ignores the LAP header on input, and a long DDP packet must
  255.    follow.
  256.  
  257. 4.6.  UDP/DDP Routing
  258.  
  259.    The following ``C'' data structure is used by KIP to internally
  260.    represent all AppleTalk routes:
  261.  
  262.        struct aroute {
  263.            u_long  node;       /* next hop/IR: AT node OR IP addr */
  264.            u_short net;        /* atalk net number, 0 if unused */
  265.            u_char  flags;      /* flags */
  266.            u_char  hops;       /* number of hops to this net */
  267.            u_char  zone;       /* zone index + 1 */
  268.            u_char  age;        /* age of entry in 20 second ticks */
  269.            u_char  port;       /* index of port route came in on */
  270.        };
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280. Budne                  Expires December 31, 1993                [Page 5]
  281.  
  282. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  283.  
  284.  
  285.        /* flag fields */
  286.  
  287.        #define arouteTYPE    0xe0   /* up to 8 types */
  288.        #define arouteCore    0x10   /* 'node' is a "core" gateway */
  289.        #define arouteAA      0x08   /* this entry received via AA */
  290.        #define arouteSUBTYPE 0x03   /* TYPE specific information */
  291.  
  292.  
  293.        /* Kbox Type */
  294.        #define arouteKbox    0x80   /* 'node' is IP addr of a Kbox */
  295.        # define arouteEtalk   0x01  /* 'net' is for Kbox EtherTalk */
  296.  
  297.        /* Net Type */
  298.        #define arouteNet    0x40    /* IP net allows directed cast */
  299.        # define arouteBMask  0x03   /* directed bcast format mask */
  300.  
  301.        /* Host Type */
  302.        #define arouteHost   0x20    /* IP rebroadcast host */
  303.        # define arouteAsync 0x02    /* virtual async atalk net */
  304.  
  305.  
  306.          Note:
  307.          The `arouteTYPE' field should be treated as an
  308.          enumeration despite the assignment of separate bits for
  309.          the existing values.
  310.  
  311.          Similarly, the `arouteSUBTYPE' bits have not always been
  312.          recognized as `arouteTYPE' specific.
  313.  
  314.          Finally, the `arouteCore' flag should be associated only
  315.          with ``Kbox'' routes.
  316.  
  317.  
  318.  
  319.    The KIP AppleTalk routing table contains three types of routes;
  320.    ``Direct'', ``Local'', and ``IP''.
  321.  
  322. 4.6.1.  Direct
  323.  
  324.    The routes for the directly connected LocalTalk and EtherTalk
  325.    networks have zero in their `hops', `node', and `flags' fields.  The
  326.    first route in KIP's routing table is for the LocalTalk port, and the
  327.    third is for the EtherTalk port (if configured).
  328.  
  329. 4.6.2.  Local
  330.  
  331.    For routes learned via RTMP on the LocalTalk or EtherTalk interfaces,
  332.    `node' is the AppleTalk node number of an AppleTalk router on the
  333.  
  334.  
  335.  
  336. Budne                  Expires December 31, 1993                [Page 6]
  337.  
  338. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  339.  
  340.  
  341.    connected network, and `port' is the index of the associated
  342.    interface.  The `flags' field is zero and the `hops' field is non-
  343.    zero.
  344.  
  345. 4.6.3.  IP
  346.  
  347.    For UDP/DDP routes (destinations that will be reached by sending the
  348.    AppleTalk DDP packet encapsulated in UDP), member `node' in the
  349.    `aroute' struct is the IP address of another Kbox or an IP network.
  350.    The flags field contains information on the type of ``IP'' route.
  351.  
  352.    AppleTalk ``IP'' routes come in four flavors; ``Net'', ``Host'',
  353.    ``Kbox'', and ``Async''.  ``Net'', ``Host'', and ``Async'' routes all
  354.    reach clients on (or connected to) IP hosts (which are not capable of
  355.    speaking ``native'' AppleTalk), while ``Kbox'' routes represent
  356.    native AppleTalk (LocalTalk and EtherTalk) networks reached by
  357.    through IP networks.
  358.  
  359. 4.6.3.1.  Net
  360.  
  361.    If the `arouteTYPE' bits of the `flags' field are equal to
  362.    `arouteNet', the AppleTalk network `net' is a UDP/DDP net coresident
  363.    with an IP network that can be reached with directed broadcasts. The
  364.    `arouteBMask' bits of the `flags' field of the `aroute' struct are
  365.    the number of low order octets (zero to three) of ones (hex `0xff')
  366.    to logically OR with the network number in the `node' field to
  367.    produce the (directed) broadcast address.  The second route in KIP's
  368.    routing table is a ``Net'' route to the directly connected
  369.    Ethernet/IP network.
  370.  
  371. 4.6.3.2.  Host
  372.  
  373.    If the `arouteTYPE' bits of the `flags' field are equal to
  374.    `arouteHost', the AppleTalk network `net' is a UDP/DDP net coresident
  375.    with an IP network that cannot be reached by directed broadcasts.
  376.    The `node' field of the `aroute' struct is the address of a
  377.    ``rebroadcast host'' which can broadcast packets on the destination
  378.    network.  KIP 06/88 does not check the ``subtype'' bits (See below
  379.    section on ``Async'' routes).
  380.  
  381. 4.6.3.3.  Kbox
  382.  
  383.    If the `arouteTYPE' bits of the `flags' field are equal to
  384.    `arouteKbox', this AppleTalk network is reached by sending the DDP
  385.    datagram encapsulated in UDP to the router located at address `node'.
  386.    ``Kbox'' routes can refer to either ``local'' routes learned by other
  387.    gateways via RTMP and distributed by the ``core'' gateway mechanism,
  388.    or routes downloaded from the AppleTalk Administrator (AA) host in
  389.  
  390.  
  391.  
  392. Budne                  Expires December 31, 1993                [Page 7]
  393.  
  394. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  395.  
  396.  
  397.    the initial route table.  The Un*x AA server implementation
  398.    distributed with KIP is `atalkad'.  The `arouteEtalk' bit in the
  399.    `arouteSUBTYPE' field exists as internal information used by
  400.    `atalkad' to differentiate LocalTalk and EtherTalk networks for
  401.    configuration purposes, and is not used by KIP at all (but is
  402.    nonetheless passed to, and saved by KIP).
  403.  
  404. 4.6.3.4.  Async
  405.  
  406.    ``Async'' is a recent extension which allows datagrams for a virtual
  407.    AppleTalk network to be forwarded to a single IP host with the UDP
  408.    port demultiplexed by DDP destination node number.  This allows the
  409.    gateway to deliver DDP datagrams for each possible node on the Async
  410.    network to a different Un*x user process with no intermediary.
  411.    ``Async'' networks are implemented as a subtype of ``Host'' networks,
  412.    with `arouteSUBTYPE' set to `arouteAsync'.  Implementations which do
  413.    not understand ``Async'' routes will treat them as ``Host'' routes,
  414.    with undesirable results.
  415.  
  416. 4.7.  IP Route Algorithms
  417.  
  418.    In ``Kbox'', ``Net'', and ``Host'' routes the destination UDP port is
  419.    demultiplexed based on the destination DDP socket (except for DDP
  420.    broadcasts to ``Host'' networks).  This allows the gateway to deliver
  421.    DDP datagrams for each possible DDP socket to a different Un*x user
  422.    process with no intermediary.
  423.  
  424.    The following table shows how the `aroute' type and the DDP
  425.    destination node select algorithms to calculate the UDP destination
  426.    port and IP destination address.
  427.  
  428.              IP dest addr algorithm / UDP dest port algorithm.
  429.  
  430.                 IP Route Type   DDP unicast   DDP broadcast
  431.                 ___________________________________________
  432.                 Net             Alg A/Alg P   Alg B/Alg P
  433.                 Host            Alg A/Alg P   Alg C/Alg Q
  434.                 Kbox            Alg C/Alg P   Alg C/Alg P
  435.                 Async           Alg C/Alg R   Alg C/Alg S
  436.  
  437.  
  438.    The UDP source port is always calculated by applying Algorithm P to
  439.    the ddp source socket.
  440.  
  441.    In the following code fragments the variable `ddp' is of type `struct
  442.    DDP' and describes the long DDP header of the outgoing AppleTalk
  443.  
  444.  
  445.  
  446.  
  447.  
  448. Budne                  Expires December 31, 1993                [Page 8]
  449.  
  450. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  451.  
  452.  
  453.    packet;
  454.  
  455.        struct DDP {
  456.            ...
  457.            u_short dstNet;         /* dest net */
  458.            u_short srcNet;         /* src net */
  459.            u_char  dstNode;        /* dest node */
  460.            u_char  srcNode;        /* src node */
  461.            u_char  dstSkt;         /* dest socket */
  462.            ...
  463.        } ddp;
  464.  
  465.  
  466.    The variable `ar' is a pointer to the `aroute' struct for the DDP
  467.    destination net in the AppleTalk routing table.
  468.  
  469. 4.7.1.  IP destination address algorithms
  470.  
  471.    The following are the algorithms for calculating the IP destination
  472.    host address of the UDP/DDP datagram expressed in ``C''.
  473.  
  474.    The variable `ip' is of type `struct ip' and describes the IP header
  475.    of the outgoing IP datagram;
  476.  
  477.        struct ip {
  478.            ...
  479.            iaddr_t ip_src;   /* IP source address */
  480.            iaddr_t ip_dst;   /* IP dest address */
  481.        } ip;
  482.  
  483.  
  484. 4.7.1.1.  Algorithm A
  485.  
  486.    Algorithm A is used to deliver unicast (non-broadcast) packets on
  487.    ``Host'' and ``Net'' networks directly to the destination host on a
  488.    UDP/DDP network.  The IP destination is formed by taking the high 24
  489.    bits from `node', and the low 8 bits from the DDP destination node
  490.    number.
  491.  
  492.        ip.ip_dst = (ar->node & ~0xff) | ddp.dstNode;
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504. Budne                  Expires December 31, 1993                [Page 9]
  505.  
  506. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  507.  
  508.  
  509. 4.7.1.2.  Algorithm B
  510.  
  511.    Algorithm B is used to broadcast packets to ``Net'' networks, relying
  512.    on directed broadcast delivery.  The IP destination is formed using
  513.    the `node' field and as many low order octets of ones as specified by
  514.    the `arouteBMask' field of `flags'.  If the destination AppleTalk
  515.    network is the connected Ethernet UDP/DDP network, the configured IP
  516.    broadcast address (member `ipbroad' in the configuration structure)
  517.    is used as the IP destination.
  518.  
  519.        u_long ipbroadtypes[] = { 0, 0xff, 0xffff, 0xffffff };
  520.  
  521.        /* directly connected UDP/DDP net? */
  522.        if( ddp.destNet == ifie.if_dnet ) {
  523.            /* use configured IP broadcast */
  524.            ip.ip_dst = conf.ipbroad;
  525.        }
  526.        else {
  527.            /* create directed broadcast */
  528.            ip.ip_dst = ar->node |
  529.                        ipbroadtypes[ ar->flags & arouteBMask ];
  530.        }
  531.  
  532.  
  533.    4.2 BSD style (zero-fill) broadcast addresses (for networks with 8
  534.    bits of host) can be generated by specifying zero octets of ones.
  535.  
  536.    Networks that cannot be reached with broadcast addresses that do not
  537.    have a integral number of low-order one-filled octets cannot use
  538.    ``Net'' routes, and must use ``Host'' routes (see below).
  539.  
  540. 4.7.1.3.  Algorithm C
  541.  
  542.    Algorithm C is used for delivery of broadcasts on ``Host'' networks,
  543.    and all packets on ``Kbox'' and ``Async'' networks to a specific host
  544.    address. The IP destination is the IP host specified in the `node'
  545.    (next IR) field .
  546.  
  547.        ip.ip_dst = ar->node;
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560. Budne                  Expires December 31, 1993               [Page 10]
  561.  
  562. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  563.  
  564.  
  565. 4.7.2.  UDP destination port algorithms
  566.  
  567.    The following are the algorithms for calculating the UDP destination
  568.    port of the UDP/DDP datagram expressed in ``C'', using the following
  569.    structure for the output UDP header;
  570.  
  571.        struct udp {
  572.            u_short     uh_src;                 /* source port */
  573.            u_short     uh_dst;                 /* destination port */
  574.            ...
  575.        } udp;
  576.  
  577.  
  578. 4.7.2.1.  Algorithm P
  579.  
  580.    Algorithm P is used for delivery of all packets on ``Net'' and
  581.    ``Kbox'' networks and unicast packets on ``Host'' networks.  Packets
  582.    for each possible DDP socket are directed to a different UDP port on
  583.    the destination host.
  584.  
  585.    ``Static'' or ``Well Known'' DDP sockets (those below 128) originally
  586.    used a UDP port base of 768 (300 hex), however in April of 1988 the
  587.    NIC reserved ports 201 through 208 (a port base of 200) for use by
  588.    KIP [RFC-1060].  UDP ports 768 and 200 are never used, since use of
  589.    DDP socket zero is illegal.  See the ``Discussion'' section below.
  590.  
  591.    The UDP port range used for static DDP sockets is configured via the
  592.    `aaCONF' packet (ie; from `atalkatab').  The UDP port range base used
  593.    for ``dynamic'' DDP sockets is fixed at 16384 (4000 hex).
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616. Budne                  Expires December 31, 1993               [Page 11]
  617.  
  618. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  619.  
  620.  
  621.        #define ddpWKSBase  200   /* start of NIC WKS range */
  622.        #define oddpWKSBase 768   /* start of old WKS range */
  623.  
  624.        #define ddpNWKSBase 16384 /* non WKS... */
  625.  
  626.        /* "well known" (ie; static) socket number?? */
  627.        if( ddp.dstSkt < 128 ) {
  628.            if( conf.startddpWKS == 0 ) {
  629.                /* no WKS range configured
  630.                 * be backwards compatible
  631.                 */
  632.                startddpWKS = oddpWKSBase;
  633.            }
  634.            else {
  635.                /* usually ddpWKSBase (200) */
  636.                startddpWKS = conf.startddpWKS;
  637.            }
  638.            udp.uh_dport = ddp.dstSkt + startddpWKS;
  639.        }
  640.        else /* not a WKS, use NWKS port range */
  641.            udp.uh_dport = ddp.dstSkt + ddpNWKSBase;
  642.  
  643.  
  644. 4.7.2.2.  Algorithm Q
  645.  
  646.    Algorithm Q is used to deliver DDP broadcasts for ``Host'' networks
  647.    to a ``rebroadcast'' server for local broadcast or selective directed
  648.    delivery.
  649.  
  650.        #define rebPort 902
  651.  
  652.        udp.uh_dport = rebPort;
  653.  
  654.  
  655. 4.7.2.3.  Algorithm R
  656.  
  657.    Algorithm R is used to deliver DDP unicast packets for ``Async''
  658.    networks to the async server host based on the DDP destination node.
  659.    This is done so that each dialin user running the `async' program can
  660.    receive packets destined for their node without additional handling
  661.    on the server host.
  662.  
  663.        #define aaBasePort 0xAA00       /* Async AppleTalk base port */
  664.  
  665.        udp.uh_dport = aaBasePort + ddp.dstNode;
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672. Budne                  Expires December 31, 1993               [Page 12]
  673.  
  674. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  675.  
  676.  
  677. 4.7.2.4.  Algorithm S
  678.  
  679.    Algorithm S is used to deliver DDP Broadcasts for ``Async'' networks
  680.    to a single UDP port so that the `asyncad' daemon can forward the
  681.    packet to all registered `async' dialin users on the Un*x host.
  682.  
  683.        #define aaBroadPort 750         /* aabroad in /etc/services */
  684.  
  685.        udp.uh_dport = aaBroadPort;
  686.  
  687.  
  688. 4.7.3.  Discussion
  689.  
  690.    The primary benefit realized by the DDP/UDP port mapping expressed in
  691.    Algorithm P is the efficient implementation of AppleTalk on systems
  692.    with a system level UDP implementation and no system level AppleTalk
  693.    (ie; Vanilla BSD Un*x), as system level UDP port demultiplexing is
  694.    used to deliver the DDP packets directly to the user process.
  695.  
  696.    Creating this one-to-one relationship between DDP sockets and UDP
  697.    ports on the UDP/DDP host is feasible because the size of the DDP
  698.    socket space is much smaller than the UDP port space (2^8 vs.  2^16).
  699.    Furthermore the UDP ports in the WKS and NWKS ranges can be used for
  700.    other purposes, but only those ports can be used for UDP/DDP
  701.    applications.
  702.  
  703.    However it is difficult to implement a UDP/DDP AppleTalk interface on
  704.    a system with both formalized UDP and DDP layers (ie; a UDP/DDP
  705.    ``adev'' for a Mac using ``MacTCP 1.0'').  A similar difficulty is
  706.    seen implementing a UDP/DDP AppleTalk router in a user process on a
  707.    system with a typical system level UDP implementation (ie; Un*x), as
  708.    the router process has to listen on and send from 254 different UDP
  709.    ports.
  710.  
  711.    Ed Moy of UCB has done work on a version of IPTalk that uses only one
  712.    UDP port for transmissions between hosts.
  713.  
  714. 4.8.  KIP UDP/DDP input processing
  715.  
  716.    When KIP receives UDP input on a port in either the ``Well Known'' or
  717.    ``Not Well Known'' DDP socket range, it strips the UDP and pseudo LAP
  718.    headers, and passes the (long) DDP packet to the regular DDP input
  719.    layer.
  720.  
  721. 4.9.  KIP Route Aging
  722.  
  723.    KIP ages all AppleTalk routes every 20 seconds.  Local (RTMP) routes
  724.    are kept for two aging periods, while learned IP routes are kept for
  725.  
  726.  
  727.  
  728. Budne                  Expires December 31, 1993               [Page 13]
  729.  
  730. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  731.  
  732.  
  733.    16 periods. Initial IP routes (from atalkad), and routes for directly
  734.    connected networks are never aged.
  735.  
  736.  
  737. 4.10.  CAP routing
  738.  
  739.    Each CAP client keeps the IP address, DDP network and node numbers of
  740.    the last host from which it received a UDP/DDP packet.  This means
  741.    that CAP is able to return some packets without sending them first to
  742.    a local gateway (in violation of Phase 1 rules)!!  If on output the
  743.    DDP destination net and node both match the cached information, the
  744.    packet is sent to the cached IP address, otherwise the packet is
  745.    routed to a single statically configured local gateway.
  746.  
  747. 4.11.  CAP socket assignment
  748.  
  749.    When a CAP client or server wishes to obtain a dynamic DDP socket it
  750.    must search the UDP port range associated with the DDP ``Not Well
  751.    Known'' socket range for a free local UDP port.  Since the UDP ports
  752.    in both the old and new ``Well Known'' (static) ranges are below
  753.    1024, only processes executing as ``super user'' may open them.
  754.  
  755.    Name Information Table (NIT) maintenance for CAP hosts is implemented
  756.    in a single process, by a program named `atis' (the appletalk
  757.    information server).  `Atis' listens on the Name Information Socket
  758.    (NIS) for `LkUp' requests and sends `LkUp-Reply' packets.  CAP
  759.    servers must send special register and unregister requests to `atis'
  760.    to modify the NIT.
  761.  
  762.    `Atis' also listens on DDP socket 4 for AppleTalk Echo Protocol (AEP)
  763.    packets, and will send an `echoReply' for each `echoRequest'
  764.    received.
  765.  
  766. 4.12.  CAP Zones
  767.  
  768.    Each CAP host is staticly configured with a zone name, and `atis'
  769.    will only answer NBP `LkUp''s in its own zone. NBP `LkUp''s sent by
  770.    KIP always include the zone (never ``*'').  See section on the magic
  771.    `ALL' zone.
  772.  
  773. 4.13.  AppleTalk Administration (AA) packets
  774.  
  775.    KIP is downloaded with a configuration that specifies only it's own
  776.    IP address, a default router and the address of an administrator host
  777.    which will supply additional configuration information.  KIP receives
  778.    this configuration information and exchanges routing information on
  779.    UDP port 901 (the `aaPort').  The packets used are called AppleTalk
  780.    Administration, or ``AA'' packets.  KIP will only accept AA packets
  781.  
  782.  
  783.  
  784. Budne                  Expires December 31, 1993               [Page 14]
  785.  
  786. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  787.  
  788.  
  789.    sent from it's configured AppleTalk Administrator host (member
  790.    `ipadmin' in configuration), IP debug host (member `ipdebug' in
  791.    configuration), or from any ``Kbox'' marked as from the AA host in
  792.    the `aroute' table.  Each packet must have a UDP source port of 901.
  793.  
  794.    KIP relies exclusively on the AA protocol to distribute routing
  795.    information for UDP/DDP networks; RTMP packets are never exchanged
  796.    over UDP/DDP networks.  All AA packets have the following structure:
  797.  
  798.         0                   1                   2                   3
  799.         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  800.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  801.        :                     aaMagic (0xFF068030)                      :
  802.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  803.        :    opcode     :     flags     :      byte count of stuff      :
  804.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  805.        :             IP address of sender (never checked)              :
  806.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  807.        :                                                               :
  808.        /                            stuff:                             /
  809.        /                  config info or route tuples                  /
  810.        /                      (up to 512 octets)                       /
  811.        :                                                               :
  812.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  813.  
  814.  
  815.    The data portion of the packet (member `stuff') is limited to 512
  816.    octets to avoid IP fragmentation.
  817.  
  818.    Here are the valid `opcode' values;
  819.  
  820.    aaCONF      1   Configuration request/reply
  821.    aaROUTEI    2   Initial routes from AA
  822.    aaROUTE     3   Route update
  823.    aaROUTEQ    4   Route update and query
  824.    aaRESTART   5   Force restart
  825.    aaZONE      6   Initial zones from AA (obs)
  826.    aaZONEQ     7   DDP ZIP over AA
  827.  
  828.  
  829.    Two recent, commonly implemented extensions (originated by the
  830.    University of Melbourne) are:
  831.  
  832.    aaROUTEM   32   More routing info
  833.    aaROUTER   33   Request routing info
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840. Budne                  Expires December 31, 1993               [Page 15]
  841.  
  842. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  843.  
  844.  
  845.    The following are AA protocol extensions which are not widely
  846.    implemented (if at all), and will not be discussed further;
  847.  
  848.    A CMU extension:
  849.  
  850.    aaROUTEIS   8   Short initial route table
  851.  
  852.  
  853.    LBL-KIP extensions (also in K-STAR 9.1);
  854.  
  855.    aaREBOOT   9    Force code download (via BOOTP)
  856.    aaRESET    10   Reset code and config
  857.  
  858.  
  859.    Extensions used by University of Melbourne;
  860.  
  861.    aaPROXY    62   NBP Proxy ARP table
  862.    aaPROXYQ   63   NBP Proxy ARP table request
  863.  
  864.  
  865.    Extensions proposed by Karen Frisa in ``IPTalk routing for AppleTalk
  866.    Phase 2'' (7/27/90), but never implemented;
  867.  
  868.    aaROUTERANGE    9    Table update with ranges
  869.    aaROUTERANGEQ   10   Table update and query with ranges
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896. Budne                  Expires December 31, 1993               [Page 16]
  897.  
  898. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  899.  
  900.  
  901. 4.13.1.  `aaCONF' packet
  902.  
  903.    On startup KIP sends a minimum length (12 byte) `aaCONF' packet to
  904.    the ``AA'' host as a configuration request. The AA host then replies
  905.    with a full configuration `conf' structure in the data portion of an
  906.    `aaCONF' packet;
  907.  
  908.  
  909.         0                   1                   2                   3
  910.         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  911.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  912.        :                    IP broadcast address *                     :
  913.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  914.        :                       IP name server **                       :
  915.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  916.        :                         IP debug host                         :
  917.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  918.        :                       IP file server **                       :
  919.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  920.        :                         ipother[0] **                         :
  921.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  922.        :                         ipother[1] **                         :
  923.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  924.        :                         ipother[2] **                         :
  925.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  926.        :                         ipother[3] **                         :
  927.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  928.        :         EtherTalk net         : start ddp WKS UDP port range  :
  929.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  930.        :                             flags                             :
  931.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  932.        :      # of static clients      :     # of dynamic clients      :
  933.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  934.        :         LocalTalk net         :          UDP/DDP net          :
  935.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  936.        :                                                               :
  937.        :                             spare                             :
  938.        :                     (was once zone info)                      :
  939.        :                                                               :
  940.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  941.  
  942.  
  943.  
  944.          Note:
  945.          Entries with * are used by KIP and passed to DDP/IP
  946.          clients via ``IPGP''.  Entries with ** are NOT used by
  947.          KIP and are passed to DDP/IP clients via ``IPGP''.
  948.  
  949.  
  950.  
  951.  
  952. Budne                  Expires December 31, 1993               [Page 17]
  953.  
  954. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  955.  
  956.  
  957.    Values for `flags' (may be OR'ed together);
  958.  
  959.    Flag               Value   Meaning
  960.    conf_stayinzone    1       No looking at other zones
  961.    conf_laserfilter   2       NBP LaserWriter filtering
  962.    conf_tildefilter   4       NBP Tilde filtering
  963.  
  964.  
  965. 4.13.2.  Routing Tuples
  966.  
  967.    `aaROUTEI', `aaROUTE', `aaROUTEQ', and `aaROUTEM' packets contain
  968.    routing tuples (called `arouteTuple''s) of the following format:
  969.  
  970.         0                   1                   2                   3
  971.         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  972.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  973.        :                        IP net or host                         :
  974.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  975.        :           atalk net           :     flags     :     hops      :
  976.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  977.  
  978.  
  979.    The `flags' field of the `arouteTuple' uses the same flags as the
  980.    `aroute' structure.
  981.  
  982.    NOTE: This differs from RTMP in that it contains the explicit address
  983.    of the ultimate destination.
  984.  
  985. 4.13.3.  `aaROUTEI' packet
  986.  
  987.    The AA host sends KIP an `aaROUTEI' packet to install an initial
  988.    (static) routing table.  On receipt of an `aaROUTEI', KIP flushes all
  989.    routes marked as ``from AA'' (with the `arouteAA' flag set), and
  990.    inserts the enclosed routes into it's routing table marked as ``from
  991.    AA''.
  992.  
  993.    The `atalkad route' command sends KIP an unsolicited `aaROUTEI'
  994.    packet.
  995.  
  996.    On startup KIP sends a minimum length (12 byte) `aaROUTEI' packet as
  997.    a request every 60 seconds until a reply is received.
  998.  
  999. 4.13.4.  `aaROUTEQ' packet
  1000.  
  1001.    Once a minute KIP sends an `aaROUTEQ' packet to a ``core'' gateway.
  1002.    Core gateways are those Kboxes which appear in KIP's routing table as
  1003.    ``Kbox'' routes with the `arouteCore' flag set.  The core gateways
  1004.    are sent to in turn, round-robin.  ``Core'' gateways send `aaROUTEQ'
  1005.  
  1006.  
  1007.  
  1008. Budne                  Expires December 31, 1993               [Page 18]
  1009.  
  1010. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1011.  
  1012.  
  1013.    as well (KIP does not contain code to detect whether it is a ``core''
  1014.    gateway or not), but a ``core'' gateway will skip it's own address.
  1015.  
  1016.    The `aaROUTEQ' packet contains ``Kbox'' routes (with the gateway IP
  1017.    address in the `node' field) for each AppleTalk route that the
  1018.    gateway has learned via RTMP (those which qualify as ``Local''
  1019.    routes).
  1020.  
  1021.    On receipt of an `aaROUTEQ' KIP merges the routes into it's routing
  1022.    table and replies with an `aaROUTE' packet containing ALL routes
  1023.    which are not marked as ``from AA''.
  1024.  
  1025. 4.13.5.  `aaROUTE' packet
  1026.  
  1027.    On receipt of an `aaROUTE' packet KIP merges the contained routes
  1028.    into it's routing table.
  1029.  
  1030. 4.13.6.  `aaRESTART' packet
  1031.  
  1032.    KIP will restart execution upon receipt of an `aaRESTART' packet.
  1033.  
  1034.    The `atalkad boot' command sends an `aaRESTART' packet to each Kbox
  1035.    in `/etc/atalkatab'.
  1036.  
  1037. 4.13.7.  `aaZONE' packet
  1038.  
  1039.    `aaZONE' is an obsolete packet format used for zone information.  KIP
  1040.    06/88 does not send or process `aaZONE' packets.  An empty `aaZONE'
  1041.    packet was sent by KIP as a request, and returned with data by
  1042.    `atalkad'.
  1043.  
  1044.    The format of `aaZONE' packet data is a list of (2 byte) AppleTalk
  1045.    network numbers terminated by a zero net number and followed by a
  1046.    ``pascal'' string (ie; string prefixed by a byte count byte) for the
  1047.    zone.  The packet is terminated by an network number of all ones (hex
  1048.    `0xffff').
  1049.  
  1050. 4.13.8.  `aaZONEQ' packet
  1051.  
  1052.    `aaZONEQ' packets contain regular DDP ZIP `Query' and `Reply'
  1053.    packets.
  1054.  
  1055.    KIP sends `aaZONEQ' packets containing ZIP `Query' requests to the AA
  1056.    host for routes marked as ``from AA'' or to the IP address in the
  1057.    `node' field of the route for routes learned via ``core'' gateways.
  1058.  
  1059.    KIP and atalkad respond to `aaZONEQ' encapsulated Queries with ZIP
  1060.    `Reply' packets inside a `aaZONEQ'.
  1061.  
  1062.  
  1063.  
  1064. Budne                  Expires December 31, 1993               [Page 19]
  1065.  
  1066. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1067.  
  1068.  
  1069. 4.13.9.  `aaROUTER' packet
  1070.  
  1071.    This is a recent extension implemented in Rutgers KIP (RU-KIP) and
  1072.    various commercial offerings.  If the `flags' field in the AA packet
  1073.    header of the `aaROUTEI' packet returned by the AA host is non-zero,
  1074.    it is interpreted as a count of the total number of initial route
  1075.    packets. The `flags' field of the AA packet header in an `aaROUTER'
  1076.    packet is interpreted as an initial route packet ``serial number''.
  1077.    Since the `aaROUTEI' packet contains the first 64 routes, the first
  1078.    `aaROUTER' request contains the value one in the `flags' field.
  1079.  
  1080. 4.13.10.  `aaROUTEM' packet
  1081.  
  1082.    This is a recent extension implemented in Rutgers KIP and various
  1083.    commercial offerings.  `Atalkad' sends the n-th additional initial
  1084.    route packet in response to the `aaROUTER' request in an `aaROUTEM'
  1085.    packet.  RU-KIP increments its request serial number regardless of
  1086.    the contents of the `flags' field in the incomming `aaROUTEM' AA
  1087.    packet header.
  1088.  
  1089. 4.14.  Aroute input Processing
  1090.  
  1091.    KIP uses the same code to integrate new routes regardless of whether
  1092.    they were acquired using the AA protocol or RTMP.  Of particular note
  1093.    is that hopcount values are incremented on input, and that worse-cost
  1094.    changes are only accepted if the new destination node matches the
  1095.    currenly saved `node' value.  Thus the AA protocol is being treated
  1096.    as a distance vector routing protocol.
  1097.  
  1098.    However, distance vector routing systems depend on the fact that
  1099.    routing tuple hopcounts reflect actual distance because the routing
  1100.    data traverses the same path as the network data.  This is not true
  1101.    for the AA protocol; Data packets are sent directly without
  1102.    traversing the core gateways through which the routing data was
  1103.    passed, so the hopcounts of routes obtained from core gateways are
  1104.    too high.
  1105.  
  1106.    In the presense of more than one core gateway, the hopcount of a core
  1107.    gateway learned route will often be inflated owing to the route being
  1108.    passed between core gateways since the ``destination'' host will be
  1109.    the same, the longer route will be accepted.  With two or more core
  1110.    gateways, routes can take more than an hour to die.
  1111.  
  1112.    Because the AppleTalk distance from any one ``Kbox'' to another is
  1113.    always one hop (the actual number of intervening IP gateways cannot
  1114.    be detected) the AppleTalk cost should be propogated though the core
  1115.    gateway routing system unchanged.  However then another metric would
  1116.    be needed limit route lifetime (by couting the number of router
  1117.  
  1118.  
  1119.  
  1120. Budne                  Expires December 31, 1993               [Page 20]
  1121.  
  1122. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1123.  
  1124.  
  1125.    traversals to ``infinity'' or by counting route ``time to live'' down
  1126.    to zero).
  1127.  
  1128. 4.14.1.  Initial routes
  1129.  
  1130.    The `atalkad' supplied with KIP 06/88 sends a hopcount of zero for
  1131.    all routes in the `aaROUTEI' packet (all other versions supply a
  1132.    hopcount of one), so all initial entries in the routing table will be
  1133.    one hop away (except for the directly connected LocalTalk, EtherTalk
  1134.    and UDP/DDP networks).
  1135.  
  1136. 4.15.  AppleTalk Administrator Packet Exchanges
  1137.  
  1138.    The following tables show AA packet exchanges involving KIP.
  1139.  
  1140. 4.15.1.  restart
  1141.  
  1142.    This occurs when an user issues the `atalkad boot' command.
  1143.    `Atalkad' sends an `aaRESTART' to each ``Kbox'' in `/etc/atalkatab'.
  1144.  
  1145.                           AA Host     KIP
  1146.                           _______________________
  1147.                           aaRESTART
  1148.                                       KIP reboots
  1149.  
  1150.  
  1151. 4.15.2.  KIP boot sequence
  1152.  
  1153.    On startup KIP requests configuration information from the AppleTalk
  1154.    Administrator (AA) host by sending minimum length `aaROUTEI' packets
  1155.    once a minute until it gets a response.
  1156.  
  1157.                    AA Host              KIP
  1158.                    _____________________________________
  1159.                                         aaCONF (no data)
  1160.                    aaCONF (with data)
  1161.  
  1162.  
  1163.    followed by either the ``atalkad route sequence'' or ``atalkad route
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176. Budne                  Expires December 31, 1993               [Page 21]
  1177.  
  1178. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1179.  
  1180.  
  1181.    sequence with extension''
  1182.  
  1183. 4.15.3.  atalkad route sequence
  1184.  
  1185.    The ``atalkad route sequence'' occurs as part of the ``KIP boot
  1186.    sequence'' or as the result of an `atalkad route' command.  The
  1187.    contents of the AA packet header `flags' field is shown in brackets.
  1188.  
  1189.                           AA Host       KIP
  1190.                           ______________________
  1191.                           aaROUTEI[0]
  1192.                                         aaROUTEQ
  1193.  
  1194.  
  1195. 4.15.4.  atalkad route sequence with extension
  1196.  
  1197.    The ``atalkad route sequence with extension'' occurs as part of the
  1198.    ``KIP boot sequence'' or as the result of an `atalkad route' command
  1199.    when the gateway implements the `aaROUTER' and `aaROUTEM' packets and
  1200.    the `flags' sent with the `aaROUTEI' packet were non-zero.
  1201.  
  1202.    The contents of the AA packet header `flags' field is shown in
  1203.    brackets.
  1204.  
  1205.                        AA Host         KIP
  1206.                        _____________________________
  1207.                        aaROUTEI[n]
  1208.                                        aaROUTER[1]
  1209.                        aaROUTEM[1]
  1210.                                        aaROUTER[2]
  1211.                        aaROUTEM[2]
  1212.                                        ...
  1213.                        ...
  1214.                                        aaROUTER[n-1]
  1215.                        aaROUTEM[n-1]
  1216.                                        aaROUTEQ
  1217.  
  1218.  
  1219. 4.15.5.  `aaZONEQ' exchange
  1220.  
  1221.    KIP sends ZIP `Query' and `Reply' packets encapsulated in `aaZONEQ'
  1222.    packets to either the AA host, or other Kboxes to acquire the zone
  1223.    name for networks reached via UDP/DDP encapsulation.
  1224.  
  1225.                   KIP                  AA Host or KIP
  1226.                   _______________________________________
  1227.                   aaZONEQ(ZIP Query)
  1228.  
  1229.  
  1230.  
  1231.  
  1232. Budne                  Expires December 31, 1993               [Page 22]
  1233.  
  1234. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1235.  
  1236.  
  1237.                                        aaZONEQ(ZIP Reply)
  1238.  
  1239.  
  1240. 4.15.6.  Core GW exchange
  1241.  
  1242.    KIP sends RTMP learned ``Local'' routes to Kboxes marked as ``core''
  1243.    gateways in it's routing table.  The core gateway responds with all
  1244.    UDP/DDP routes not marked as ``from AA''.
  1245.  
  1246.                           KIP        KIP Core GW
  1247.                           ______________________
  1248.                           aaROUTEQ
  1249.                                      aaROUTE
  1250.  
  1251.  
  1252. 4.16.  Rebroadcast Port
  1253.  
  1254.    KIP accepts UDP packets on port 902 (the `rebPort') if the
  1255.    destination IP address matches the gateway address (broadcasts are
  1256.    not accepted, nor are packets rerouted), and passed to the ddpinput
  1257.    routine for processing based on the embedded DDP destination.
  1258.  
  1259.    If the packet is a DDP broadcast, KIP will broadcast the packet using
  1260.    the configured broadcast address as the IP destination, while the
  1261.    Un*x `atalkrd' server distributed with KIP can be given a list of
  1262.    addresses (via command line arguments) for forwarding packets.
  1263.  
  1264. 4.17.  `atalkatab'
  1265.  
  1266.    The Un*x AA server implementation distributed with KIP is called
  1267.    `atalkad', and the configuration file read by atalkad is called
  1268.    `atalkatab'.
  1269.  
  1270.    atalkatab format is best compared to assembly language; each line is
  1271.    a textual representation of binary structures to be generated and
  1272.    stored for later retrieval.
  1273.  
  1274. 4.17.1.  route line format
  1275.  
  1276.    Initial routes and zones to be sent in `aaROUTEI', `aaROUTEM' and
  1277.    `aaZONEQ' replies are generated by ``route lines'' of the following
  1278.    format;
  1279.  
  1280.    net   flags   ipaddr   zone
  1281.  
  1282.  
  1283.    Where net is the DDP net to be configured.  As mentioned earlier,
  1284.    nets may be represented as a pair of dotted decimal octets, or as a
  1285.  
  1286.  
  1287.  
  1288. Budne                  Expires December 31, 1993               [Page 23]
  1289.  
  1290. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1291.  
  1292.  
  1293.    simple decimal integer.
  1294.  
  1295.    flags is a series of mnemeonic characters which represent values to
  1296.    ``OR'' together to generate the `arouteTuple' flags field;
  1297.  
  1298.                    character(s)   bit(s)
  1299.                    _____________________________________
  1300.                    0123           arouteBmask
  1301.                    A              arouteHost+arouteAsync
  1302.                    C              arouteCore
  1303.                    E              arouteKbox+arouteEtalk
  1304.                    K              arouteKbox
  1305.                    H              arouteHost
  1306.                    N              arouteNet
  1307.  
  1308.  
  1309.    The digits zero through three the corresponding binary value  to  be
  1310.    ``ORed'' into the flags field (to set the ``Net'' broadcast format).
  1311.  
  1312.    ipaddr is an IP address to be stored in the `node' field.
  1313.  
  1314. 4.17.2.  Kbox configuration section
  1315.  
  1316.    Configuration for ``Kboxes'' to be sent in `aaCONF' packets is
  1317.    represented on whitespace prefixed lines following a K line.
  1318.    Configuration information is a series of key-characters which control
  1319.    both the interpretation of the data to follow, and the amount of data
  1320.    to be stored.
  1321.  
  1322.    key   interpretation            size in bytes
  1323.    _____________________________________________
  1324.    I     Internet host name/addr   4
  1325.    L     Long integer              4
  1326.    S     Short integer             2
  1327.    %n    net config                2
  1328.    B     Byte integer              1
  1329.  
  1330.  
  1331.    Integer data is interpreted as decimal unless prefixed with the
  1332.    letter `X', numbers prefixed with a leading zero are interpreted as
  1333.    octal.  Short integers can be entered as dotted pairs.
  1334.  
  1335.    The pair of characters `%n' has magic properties when it appears at
  1336.    the data offsets associated with the configuration for each of the
  1337.    AppleTalk ``ports''; LocalTalk, EtherTalk, and UDP/DDP.
  1338.  
  1339.    For the LocalTalk port `%n' takes on the value of the net number on
  1340.    the preceding `K' line.  For the EtherTalk port `%n' takes on the
  1341.  
  1342.  
  1343.  
  1344. Budne                  Expires December 31, 1993               [Page 24]
  1345.  
  1346. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1347.  
  1348.  
  1349.    value of the net number on the first preceding `E' line where the
  1350.    ipaddr of the `E' line matches the IP address of the current Kbox.
  1351.    For the UDP/DDP port `%n' takes on the value of the net number on the
  1352.    first `H' or `N' line where the top three bytes of the ipaddr of the
  1353.    `H' or `N' line matches the IP address of the current Kbox.
  1354.  
  1355.    In addition strings of characters may be entered delimited with
  1356.    ``quote'' character (ASCII 34).  Counted ``PASCAL'' strings may be
  1357.    entered delimited with the ``accent grave'' or ``backquote''
  1358.    character (ASCII 96).
  1359.  
  1360. 4.18.  Related DDP in IP encapsulations
  1361.  
  1362.    KIP-style DDP in IP encapsulation has been used in two other
  1363.    contexts.  Both use the same pseudo-LAP header as KIP UDP/DDP, but
  1364.    use different UDP ports.
  1365.  
  1366. 4.18.1.  UAB ``mKIP'' encapsulation
  1367.  
  1368.    UAB (Un*x AppleTalk Bridge) is a Phase 1 AppleTalk Router which runs
  1369.    on Un*x systems and speaks EtherTalk Phase 1.  UAB communicates with
  1370.    CAP client software on the local host (via UDP to the loopback
  1371.    address) using an encapsulation called ``modified KIP''.  Because it
  1372.    would be impossible to configure CAP with the local host as the
  1373.    ``bridge node'' (both because this would require opening more than
  1374.    200 Un*x ``sockets'', and because doing so would prevent the clients
  1375.    from opening any), UAB listens on the UDP port 903 (the `mrebPort'),
  1376.    for packets from local clients to be routed to EtherTalk.
  1377.  
  1378.  
  1379. 4.18.2.  Point to Point links using RTMP
  1380.  
  1381.    Cayman and other vendors use KIP style DDP/IP encapsulation on UDP
  1382.    port 910 to implement point to point ``tunnels'' between gateways.
  1383.    Phase 2 RTMP and ZIP are sent (to and from DDP net and node zero)
  1384.    across the ``link'' (as determined by IP source) to exchange routing
  1385.    and zone information.
  1386.  
  1387.    Owing to the high update rate of RTMP, it is impractical to create
  1388.    large fully connected routing systems due to the quadratic number of
  1389.    links (n^2 - n) and update packets.
  1390.  
  1391. 5.  NBP Filtering
  1392.  
  1393.    KIP performs three types of NBP based filtering; ``Stay in Zone'',
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400. Budne                  Expires December 31, 1993               [Page 25]
  1401.  
  1402. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1403.  
  1404.  
  1405.    ``LaserWriter'', and ``Tilde''.
  1406.  
  1407.          Note:
  1408.  
  1409.  
  1410. 5.1.  Stay in Zone filtering
  1411.  
  1412.    ``Stay in Zone'' filtering (enabled by the `conf_stayinzone' flag) is
  1413.    the most restrictive type.  If enabled, machines on the gateway
  1414.    LocalTalk will only be able to access resources within their own zone
  1415.    through KIP.  Access to ANY resource outside this zone will be
  1416.    prevented.
  1417.  
  1418.    ``Stay in Zone'' filtering is implemented by never sending NBP `LkUp'
  1419.    requests (when expanding NBP `BrRq' requests) to nets which are not
  1420.    in the same zone as the LocalTalk port, and by sending empty replies
  1421.    for ZIP `GetZoneList' requests, so that no zone list appears in the
  1422.    Macintosh ``chooser''.
  1423.  
  1424. 5.2.  LaserWriter filtering
  1425.  
  1426.    ``LaserWriter filtering'' (enabled by the `conf_laserfilter' flag)
  1427.    allows free access to LaserWriters in the gateway's LocalTalk zone by
  1428.    all members of this zone.  However machines outside this zone will be
  1429.    unable to see any LaserWriters behind this Kbox.
  1430.  
  1431.    ``LaserWriter filtering'' is implemented by routing NBP `LkUp-Reply'
  1432.    packets which contain NBP type `LaserWriter' ONLY if the source net
  1433.    is in the same zone as the gateway's LocalTalk or the source and
  1434.    destination nets are both in the gateway's LocalTalk zone.
  1435.  
  1436.          Note:
  1437.          Absolute determination of the source and destination
  1438.          zones from net numbers are only possible in an AppleTalk
  1439.          Phase 1 environment!
  1440.  
  1441.  
  1442. 5.3.  Tilde filtering
  1443.  
  1444.    ``Tilde filtering'' (enabled by the `conf_tildefilter' flag) is
  1445.    similar to ``LaserWriter Filtering''.  By default, all NBP names will
  1446.    be accessible outside the gateway LocalTalk zone.  However if an NBP
  1447.    entity name ends in the tilde character ``~'' (e.g.  `Our Printer~'),
  1448.    then this name will no be seen by machines outside of the zone.
  1449.  
  1450.          Note:
  1451.          When KIP performs `LaserWriter' and ``Tilde'' filtering
  1452.          it only looks at the first tuple of the NBP `LkUp-Reply'
  1453.  
  1454.  
  1455.  
  1456. Budne                  Expires December 31, 1993               [Page 26]
  1457.  
  1458. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1459.  
  1460.  
  1461.          packet.  If the first tuple matches the filtering test,
  1462.          the entire packet will be dropped.  If the first tuple
  1463.          fails the filtering test the entire packet will be
  1464.          dropped.
  1465.  
  1466.  
  1467. 6.  Magic `ALL' zone
  1468.  
  1469.    The zone name `ALL' has magic properties to KIP; it allows CAP hosts
  1470.    on an Ethernet with one gateway to appear in disparate zones.  NBP
  1471.    `LkUp''s are always sent to nets in zone `ALL', regardless of the
  1472.    target zone in the `BrRq' packets.  KIP will never return the zone
  1473.    name `ALL' in a ZIP `GetZoneList' reply, so it will never be seen in
  1474.    a list of zones (ie; Mac ``Chooser'' or CAP `getzones').  Since KIP
  1475.    always replaces ``*'' with the source zone of the `BrRq' and `atis'
  1476.    checks the zone on incoming `LkUp''s each CAP host will only appear
  1477.    in one zone.
  1478.  
  1479. 7.  Gateway Debug protocol
  1480.  
  1481.    KIP provides for remote examine and deposit of memory locations by
  1482.    the configured `ipdebug' host via packets sent to UDP port 900 (the
  1483.    `gwdbPort').
  1484.  
  1485.         0                   1                   2                   3
  1486.         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1487.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1488.        :                    gwdbMagic (0xFF068020)                     :
  1489.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1490.        :      op       :      seq      :             count             :
  1491.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1492.        :                            address                            :
  1493.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1494.        :                                                               :
  1495.        /                             data                              /
  1496.        /                      (up to 512 octets)                       /
  1497.        :                                                               :
  1498.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1499.  
  1500.  
  1501.    `op' codes for gwdb;
  1502.  
  1503.    gwdbRead    1   Read memory
  1504.    gwdbWrite   2   Write memory
  1505.    gwdbCall    3   Not implemented
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512. Budne                  Expires December 31, 1993               [Page 27]
  1513.  
  1514. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1515.  
  1516.  
  1517.    LBL KIP uses the following op codes:
  1518.  
  1519.    gwdbStats   4   Return statistics
  1520.    gwdbState   5   Return configuration
  1521.    gwdbFrame   6   Return stack frame
  1522.  
  1523.  
  1524.    Shiva uses the following op code for remote debug with GDB:
  1525.  
  1526.    gwdbGdb   99
  1527.  
  1528.  
  1529. 7.1.  gwdb Read function
  1530.  
  1531.    `count' octets starting at `address' in the gateway memory are copied
  1532.    to `data', and the packet is returned.
  1533.  
  1534. 7.2.  gwdb Write function
  1535.  
  1536.    `count' octets of data from `data' are copied to `address' in the
  1537.    gateway memory and the packet is returned unmodified.
  1538.  
  1539. 7.3.  gwdb Call function
  1540.  
  1541.    KIP does not implement this function!  For unimplemented functions
  1542.    KIP clears the `op' byte and returns the packet.
  1543.  
  1544. 7.4.  gwdb State function
  1545.  
  1546.    This function is implemented by LBL KIP and K-STAR, and returns
  1547.    FastPath specific information in `data';
  1548.  
  1549.        /*
  1550.         * Structure of data area in a 'state' reply.
  1551.         */
  1552.        struct gwdb_State {
  1553.            struct fp_version version;
  1554.            struct fp_state state;
  1555.        };
  1556.  
  1557.  
  1558. 7.5.  gwdb Stats function
  1559.  
  1560.    This function is implemented only by LBL KIP.
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568. Budne                  Expires December 31, 1993               [Page 28]
  1569.  
  1570. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1571.  
  1572.  
  1573. 7.6.  gwdb Frame function
  1574.  
  1575.    This function is implemented by LBL KIP and K-STAR and returns the
  1576.    machine state of the processor; D0-D7, A0-A7, SR (left padded to 32
  1577.    bits).
  1578.  
  1579. 7.7.  gwdb Gdb function
  1580.  
  1581.    Shiva uses this function.  The following remote gdb commands are
  1582.    supported:
  1583.  
  1584.     Command        Function                                Return value
  1585.     ___________________________________________________________________
  1586.     g              return the value of the CPU registers   ENN / data
  1587.     G              set the value of the CPU registers      ENN / OK
  1588.     mAA..AA,LLLL   Read LLLL octets at address AA..AA      ENN / data
  1589.     MAA..AA,LLLL   Write LLLL octets at address AA..AA     ENN / OK
  1590.     c[AA..AA]      Continue [at address AA..AA]            SNN
  1591.     s[AA..AA]      Step one instruction [from AA..AA]      SNN
  1592.     ?              What was the last signal?               SNN
  1593.     k              kill (ignored)
  1594.  
  1595.  
  1596.    Where ``AA..AA'', ``LLLL'' and ``NN'' are in hex.  ``SNN'' represents
  1597.    an exception encoded as a Un*x `signal' number NN and ``ENN''
  1598.    represents an error condition.  All returns marked ``data'' are
  1599.    streams of octets encoded in hexadecimal.
  1600.  
  1601. 8.  DDP/IP encapsulation
  1602.  
  1603.       Note:
  1604.       While the Apple-IP Working Group of the IETF is working to
  1605.       standardize and extend the protocols for IP over AppleTalk,
  1606.       however no description exists of the historical
  1607.       implementation.
  1608.  
  1609.  
  1610.    KIP provides an IP ``forwarding'' capability that allows AppleTalk
  1611.    nodes appear to be located on the Ethernet by sending ``proxy ARP''
  1612.    replies for IP addresses in a ``client range''.
  1613.  
  1614.    The DDP/IP encapsulation protocol consists of three parts;
  1615.    Encapsulation, Dynamic address assignment, and Address Resolution.
  1616.  
  1617. 8.1.  Encapsulation
  1618.  
  1619.    IP Datagrams are encapsulated in DDP packets of type 22 with DDP
  1620.    source and destination sockets of 72.
  1621.  
  1622.  
  1623.  
  1624. Budne                  Expires December 31, 1993               [Page 29]
  1625.  
  1626. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1627.  
  1628.  
  1629. 8.2.  Address Resolution
  1630.  
  1631.    KIP uses AppleTalk NBP `LkUp''s to achieve IP address resolution.
  1632.    This allows routing of IP packets within an AppleTalk zone, without
  1633.    requiring any changes to intermediate DDP routers within the zone.
  1634.  
  1635.    Each DDP/IP host must NBP register a tuple of type `IPADDRESS' with
  1636.    the object name set to the dotted decimal representation of the
  1637.    host's IP address.  This ensures that only one host is using an IP
  1638.    address at a time, and allows hosts (both Macintoshes and KIP) to
  1639.    locate each other by address using NBP.
  1640.  
  1641.    KIP maintains DDP addresses alongside Ethernet addresses in it's ARP
  1642.    cache. When KIP needs to route an IP packet to a client (static or
  1643.    dynamic) which does not appear in the cache, it performs an NBP
  1644.    lookup (as `a.b.c.d:IPADDRESS') in the zone associated with the Kbox
  1645.    LocalTalk port.  Because of this clients must be located in the same
  1646.    zone as the Kbox.
  1647.  
  1648.    NBP replies for type `IPADDRESS' are always processed as both ARP
  1649.    replies and dynamic address confirmations.
  1650.  
  1651. 8.2.1.  NBP Proxy ARP
  1652.  
  1653.    In order to maintain the illusion that the DDP/IP hosts are located
  1654.    on Ethernet, KIP must reply in proxy for NBP ARP's for addresses NOT
  1655.    in the gateway client range (as opposed to on Ethernet where KIP
  1656.    replies for addresses in the client range) as well as it's own IP
  1657.    address so that packets for hosts that are really on the Ethernet are
  1658.    routed via the gateway!
  1659.  
  1660.    KIP does not reply to NBP ARP's in it's client range to allow clients
  1661.    to NBP register (which requires first performing a zone wide search
  1662.    for current users of a name). This would prevent more than one
  1663.    gateway from operating in the same zone (since one gateway or the
  1664.    other will reply to any IPADDRESS lookup) however, KIP will only send
  1665.    replies for lookups of type IPADDRESS if the reply would be routed
  1666.    via the LocalTalk port.
  1667.  
  1668.    Some DDP/IP client software attempts to resolve all IP addresses into
  1669.    a DDP destination using NBP ARP (depending on NBP Proxy ARP Replies
  1670.    from the gateway), while others will only NBP ARP for addresses which
  1671.    are on the connected IP network (as determined by it's own IP address
  1672.    and a (sub)net mask), and route all other packets via a default
  1673.    gateway on the connected net.
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680. Budne                  Expires December 31, 1993               [Page 30]
  1681.  
  1682. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1683.  
  1684.  
  1685. 8.2.2.  DDP ARP
  1686.  
  1687.    Another method was previously used for DDP/IP IP Address Resolution.
  1688.    Work done in the summer of 1984 at Dartmouth [Sherman86] treated the
  1689.    LocalTalk as a distinct IP network, and sent ARP [RFC-826] using DDP
  1690.    type 23, and hardware type 3 for ``AppleBus''.
  1691.  
  1692.    This method requires that an entire IP (sub)net be assigned for use
  1693.    by LocalTalk hosts, and at the same time limits the IP (sub)net to a
  1694.    single LocalTalk wire.  IP addresses on the LocalTalk (sub)net can
  1695.    either be assigned staticly, or the host's LAP node number can be
  1696.    used as the IP address host part to provide a dynamic IP address!
  1697.  
  1698.    The original SEAGate code converted between IP and DDP addresses by
  1699.    equating the DDP net number and IP subnet numbers.
  1700.  
  1701. 8.3.  Dynamic Address Assignment
  1702.  
  1703.    So that each potential client need not be configured with an IP
  1704.    address (and that a large number of clients can share a small pool of
  1705.    addresses), KIP can perform IP address assignment on an on-demand
  1706.    basis from a pool of ``dynamic'' addresses.
  1707.  
  1708.    KIP receives configuration for the number of static and dynamic
  1709.    clients from atalkatab.  Up to 60 dynamic addresses can be
  1710.    configured.  Static client addresses follow directly after the
  1711.    gateway address, and dynamic addresses follow after the static
  1712.    addresses.
  1713.  
  1714.    So that potential dynamic clients can locate the gateway, KIP
  1715.    responds to NBP `LkUp''s of type `IPGATEWAY' with the dotted decimal
  1716.    representation of it's address as the object name, and socket number
  1717.    72.  KIP will only respond to lookups of type `IPGATEWAY' if it would
  1718.    route the reply via it's LocalTalk port.  This keeps different Mac's
  1719.    in the same zone, but behind a different gateway on the same Ethernet
  1720.    from getting an address from the wrong box!
  1721.  
  1722.    For each dynamic address, KIP keeps the following three-tuple: `net',
  1723.    `node', `timer'.  Where `net' and `node', is the client's DDP
  1724.    address, and `timer' counts how many minutes have passed since the
  1725.    entry has been successfully ``confirmed''.  A non-zero `timer' value
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736. Budne                  Expires December 31, 1993               [Page 31]
  1737.  
  1738. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1739.  
  1740.  
  1741.    indicates the entry is in use.
  1742.  
  1743. 8.3.1.  IPGATEWAY Protocol
  1744.  
  1745.    The protocol used for dynamic address assignment is called IPGP (for
  1746.    the IPGATEWAY Protocol), and is sent using ATP.  KIP processes IPGP
  1747.    packets received on DDP socket 72 (KIP accepts and replies to both XO
  1748.    and ALO ATP requests, but provides only ALO service).
  1749.  
  1750. 8.3.1.1.  ipgp packet format
  1751.  
  1752.    The four ATP ``user bytes'' (in the ATP header) are ignored.
  1753.  
  1754.         0                   1                   2                   3
  1755.         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  1756.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1757.        :                              op                               :
  1758.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1759.        :                          IP address                           :
  1760.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1761.        :                        IP name server                         :
  1762.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1763.        :                     IP broadcast address                      :
  1764.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1765.        :                        IP file server                         :
  1766.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1767.        :                          ipother[0]                           :
  1768.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1769.        :                          ipother[1]                           :
  1770.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1771.        :                          ipother[2]                           :
  1772.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1773.        :                          ipother[3]                           :
  1774.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1775.        :                                                               :
  1776.        /                                                               /
  1777.        /                      string (128 octets)                      /
  1778.        /                                                               /
  1779.        :                                                               :
  1780.        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1781.  
  1782.  
  1783. 8.3.1.2.  functions
  1784.  
  1785.    ipgpAssign   1   Assign new IP address
  1786.    ipgpName     2   Name lookup
  1787.    ipgpServer   3   Return just server addresses
  1788.  
  1789.  
  1790.  
  1791.  
  1792. Budne                  Expires December 31, 1993               [Page 32]
  1793.  
  1794. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1795.  
  1796.  
  1797.    ipgpRange    4   Return start address and range
  1798.    ipgpVerify   5   Verify this IP address is mine
  1799.  
  1800.  
  1801.    Only `ipgpAssign' and `ipgpServer' have ever been implemented by KIP.
  1802.    If an error occurs processing an IPGP packet, KIP sets `op' to -1
  1803.    (all ones), and returns a zero terminated error message in the
  1804.    `string' field.  The string `bad op' is returned if the `op' field is
  1805.    not either `ipgpAssign' or `ipgpServer'.
  1806.  
  1807. 8.3.1.3.  ipgp Assign function
  1808.  
  1809.    The `ipgpAssign' function attempts to allocate an available dynamic
  1810.    IP address using the following criteria (in descending preference);
  1811.  
  1812. (1)
  1813.    The lowest IP address for which the saved DDP address associated with
  1814.    the dynamic IP address matches the DDP source address of the
  1815.    `ipgpAssign' packet.
  1816.  
  1817. (2)
  1818.    The highest IP address entry that has never been used (ie; `timer' is
  1819.    zero).
  1820.  
  1821. (3)
  1822.    The oldest entry which is more than five minutes old.
  1823.  
  1824. (4)
  1825.    If no entry has been idle (failed address confirmation) more than
  1826.    five times, then address assignment fails, and the packet is returned
  1827.    with `op' set to -1 and `string' is set to `no free address'.
  1828.  
  1829.    If an address is successfully (re)assigned it will be returned in the
  1830.    `ipaddress' field of the IPGP packet, the client DDP address is saved
  1831.    in the dynamic client table, and the entry timer is set to one.  The
  1832.    IPGP `op' field is returned unmodified.  The `ipname', `ipbroad',
  1833.    `ipfile' and `ipother' fields are filled in with data received from
  1834.    the AA host via an `aaROUTEI' packet.
  1835.  
  1836. 8.3.1.4.  ipgp Server function
  1837.  
  1838.    The `ipgpServer' function returns the auxiliary data fields returned
  1839.    by `ipgpAssign' but without assigning an address. This function can
  1840.    be used by ``static'' clients.
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848. Budne                  Expires December 31, 1993               [Page 33]
  1849.  
  1850. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1851.  
  1852.  
  1853. 8.3.2.  reboot and address confirmation
  1854.  
  1855.    KIP sends NBP `LkUp' packets to locate and confirm users of dynamic
  1856.    IP address slots.
  1857.  
  1858.    To provide robustness in case of gateway failure KIP will attempt to
  1859.    (re)acquire the address associations in use before the gateway
  1860.    restarted.  After configuration is complete KIP waits 25 seconds (to
  1861.    allow RTMP routes to be established) and it sends out wildcard NBP
  1862.    `LkUp' packets for type `IPADDRESS' in the zone associated with it's
  1863.    LocalTalk once a second for five seconds.  Incoming NBP packets with
  1864.    type `IPADDRESS' are passed (as usual) to both NBP ARP input
  1865.    processing and Dynamic IP Address confirm processing.  This reloads
  1866.    the Dynamic IP Address table with all active users (within the local
  1867.    zone).
  1868.  
  1869.    Once KIP has been running for 30 seconds, KIP attempts to ``confirm''
  1870.    the NBP `IPADDRESS' associated with each dynamic IP address ``slot''
  1871.    once a minute.  Since a maximum of 60 dynamic addresses may be
  1872.    allocated by KIP, each entry is confirmed on the same ``tick'' of the
  1873.    second hand, spreading the NBP traffic out.  If the aging timer
  1874.    associated with an entry is zero (an unused entry) or has reached
  1875.    32767 no confirm is sent.
  1876.  
  1877.    The confirm packet is an NBP `LkUp' packet (with type object `=' and
  1878.    zone `*') sent directly to the to the DDP address found in the
  1879.    dynamic IP address table.
  1880.  
  1881.    Upon receipt of an NBP reply for an IPADDRESS in the dynamic range
  1882.    the address confirmation code saves the replying entity's DDP address
  1883.    in the dynamic client table, and resets the entry timer to one.
  1884.  
  1885. 9.  KIP revision history
  1886.  
  1887.    Below is an edited revision history for KIP.
  1888.  
  1889. 9.1.  10/86
  1890.  
  1891.    Improved IP address management (IPGP + NBP ARP).  Centralized
  1892.    configuration and boot control.  Full AppleTalk routing using
  1893.    NBP/RTMP/ZIP; ``core'' gateway scheme.  Gateway debugging via net
  1894.    ddt.  Simple integration with libraries such as CAP/K-HOST.  Improved
  1895.    packet throughput.  (Croft)
  1896.  
  1897. 9.2.  02/87
  1898.  
  1899.    Bug fixes.  (Croft)
  1900.  
  1901.  
  1902.  
  1903.  
  1904. Budne                  Expires December 31, 1993               [Page 34]
  1905.  
  1906. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1907.  
  1908.  
  1909. 9.3.  09/87
  1910.  
  1911.    Implement zones `(aaZONE)' and zone filtering.  (Croft and Kim)
  1912.  
  1913. 9.4.  01/88
  1914.  
  1915.    Ethertalk support.  Magic zone name `ALL'.  ATP ZIP support
  1916.    rewritten.  DDP Echo support.  atalkad configuration aids.  (Kim and
  1917.    Tappan)
  1918.  
  1919. 9.5.  06/88
  1920.  
  1921.    Support for NIC UDP port range.  Zone acquisitions are done on RTMP
  1922.    routes.  EtherTalk fixes.  Allzones was on for ``unknown'' zones.
  1923.    (Kim)
  1924.  
  1925. 10.  NIC Assigned UDP ports
  1926.  
  1927.    The following UDP ports were assigned for UDP/DDP encapsulation in
  1928.    April of 1988 [RFC-1060].
  1929.  
  1930.               Port   NIC Name   Use
  1931.               _______________________________________________
  1932.               201    AT-RMTP    AppleTalk Routing Maintenance
  1933.               202    AT-NBP     AppleTalk Name Binding
  1934.               203    AT-3       AppleTalk Unused
  1935.               204    AT-ECHO    AppleTalk Echo
  1936.               205    AT-5       AppleTalk Unused
  1937.               206    AT-ZIS     AppleTalk Zone Information
  1938.               207    AT-7       AppleTalk Unused
  1939.               208    AT-8       AppleTalk Unused
  1940.  
  1941.  
  1942.    In regular operation RTMP and ZIP are never sent in UDP/DDP packets.
  1943.    The CAP `getzones' command sends ZIP `GetZoneList' packets to KIP,
  1944.    but KIP always sends ZIP `Query' commands in `aaZONEQ' packets to
  1945.    it's AA host and other Kboxes.  The NBP and ECHO are ports are served
  1946.    by `atis' on CAP hosts.
  1947.  
  1948. 11.  Non-NIC Assigned UDP ports:
  1949.  
  1950.    The following ports are used by KIP, CAP or work-alikes, but have not
  1951.    been assigned by the Internet Assigned Numbers Authority;
  1952.  
  1953.         Port(s)       Name          Use
  1954.         ___________________________________________________________
  1955.         750           aaBroadPort   Async Appletalk broadcast
  1956.  
  1957.  
  1958.  
  1959.  
  1960. Budne                  Expires December 31, 1993               [Page 35]
  1961.  
  1962. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  1963.  
  1964.  
  1965.         768-895       ddpWKSUnix    Old DDP Well-Known socket range
  1966.         899                         FastPath KLAP3 over UDP
  1967.         900           gwdbPort      Gateway Debug Protocol
  1968.         901           aaPort        AA Protocol
  1969.         902           rebPort       UDP/DDP Rebroadcast
  1970.         903           mrebPort      UAB mKIP Rebroadcast
  1971.         910                         RTMP Point-to-Point
  1972.         16512-16639   ddpNWKSUnix   Non-Well-Known DDP Socket range
  1973.         43520         aaBasePort    Async Appletalk base port
  1974.  
  1975.  
  1976. 12.  Programmer's Reference:
  1977.  
  1978.    The following are the ``C'' data structure declarations used by KIP
  1979.    for packets described in this memo;
  1980.  
  1981.          Note:
  1982.          All data is in ``network'' (native 68000) byte order.
  1983.  
  1984.  
  1985.    AppleTalk administration packets from AppleTalk administrator host
  1986.    (AA) or other gateways; configuration / routing information packet.
  1987.  
  1988.        struct aaconf {
  1989.            u_long  magic;       /* magic number aaMagic */
  1990.            u_char  type;        /* op code */
  1991.            u_char  flags;
  1992.            u_short count;       /* byte count of 'stuff' */
  1993.            iaddr_t ipaddr       /* IP address of sender */
  1994.            u_char  stuff[512];  /* config info or route tuples */
  1995.        };
  1996.  
  1997.        #define aaconfMinSize 12
  1998.        #define aaPort    901    /* udp port number */
  1999.        #define aaMagic   ((u_long)0xFF068030)
  2000.  
  2001.  
  2002.  
  2003.    Routing tuple contained in all `aaROUTE*' packets;
  2004.  
  2005.  
  2006.        struct arouteTuple {
  2007.            long    node;           /* IP net or host address */
  2008.            u_short net;            /* atalk net number */
  2009.            u_char  flags;          /* flags, see aroute */
  2010.            u_char  hops;           /* hop count */
  2011.        };
  2012.  
  2013.  
  2014.  
  2015.  
  2016. Budne                  Expires December 31, 1993               [Page 36]
  2017.  
  2018. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  2019.  
  2020.  
  2021.    Configuration information from `aaCONF' packet;
  2022.  
  2023.  
  2024.        struct conf {
  2025.            iaddr_t ipbroad;         /* IP broadcast addr */
  2026.            iaddr_t ipname;          /* address of name server */
  2027.            iaddr_t ipdebug;         /* address of debug host */
  2028.            iaddr_t ipfile;          /* address of file server */
  2029.            u_long  ipother[4];      /* other addresses for IPGP */
  2030.            u_short anetet;          /* EtherTalk AT net # */
  2031.            u_short startddpWKS;     /* UDP WKS range start */
  2032.            u_long  flags;           /* various bit flags */
  2033.        #define conf_stayinzone  0x1 /* no looking at other zones */
  2034.        #define conf_laserfilter 0x2 /* NBP filter LaserWriters */
  2035.        #define conf_tildefilter 0x4 /* NBP filter "name~" */
  2036.            u_short ipstatic;        /* static IP addrs */
  2037.            u_short ipdynamic;       /* dynamic IP addrs */
  2038.            u_short atneta;          /* LocalTalk AT net # */
  2039.            u_short atnete;          /* UDP/DDP AT net # */
  2040.            u_char  spare[16];       /* was once zone info */
  2041.        };
  2042.  
  2043.  
  2044.  
  2045.    Gateway debug protocol (via ddt68 on Un*x);
  2046.  
  2047.  
  2048.        struct gwdb {
  2049.            u_long  magic;          /* magic number gwdbMagic */
  2050.            u_char  op,seq;         /* op code, sequence number */
  2051.            u_short count;          /* byte count */
  2052.            u_long  address;        /* address of read/write */
  2053.            u_char  data[512];
  2054.        };
  2055.  
  2056.  
  2057.        #define gwdbMagic       ((u_long)0xFF068020)
  2058.        #define gwdbPort        900     /* udp port number */
  2059.  
  2060.        /* op codes */
  2061.        #define gwdbRead        1
  2062.        #define gwdbWrite       2
  2063.        #define gwdbCall        3
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072. Budne                  Expires December 31, 1993               [Page 37]
  2073.  
  2074. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  2075.  
  2076.  
  2077.    IPGATEWAY protocol ATP packet used by client MacIP programs to
  2078.    request name assignment and lookup services.
  2079.  
  2080.  
  2081.        struct IPGP {
  2082.            u_long  op;             /* opcode */
  2083.            long    ipaddress;      /* my IP address (or lookup reply)*/
  2084.            long    ipname;         /* address of my name server */
  2085.            long    ipbroad;        /* my broadcast address */
  2086.            long    ipfile;         /* my file server */
  2087.            long    ipother[4];     /* other addresses/flags */
  2088.            char    string[128];    /* null terminated error string */
  2089.        };
  2090.  
  2091.  
  2092.        #define ipgpMinSize  36
  2093.  
  2094.        /* op codes */
  2095.        #define ipgpAssign   1      /* assign new IP address */
  2096.        #define ipgpName     2      /* name lookup */
  2097.        #define ipgpServer   3      /* just return my server addresses */
  2098.        #define ipgpRange    4      /* return start address and range */
  2099.        #define ipgpVerify   5      /* verify this IP address is mine */
  2100.        #define ipgpError    -1     /* error return; string=message */
  2101.  
  2102.  
  2103. 13.  Author's Note:
  2104.  
  2105.    Portions of this document were copied from KIP source files covered
  2106.    by the following copyrights:
  2107.  
  2108.        (C) 1984, Stanford Univ. SUMEX project.
  2109.        May be used but not sold without permission.
  2110.  
  2111.        (C) 1986, Kinetics, Inc.
  2112.        May be used but not sold without permission.
  2113.  
  2114.        (C) 1986, Stanford, BBN, Kinetics.
  2115.        May be used but not sold without permission.
  2116.  
  2117.        (C) 1986, Stanford Univ. CSLI.
  2118.        May be used but not sold without permission.
  2119.  
  2120.        (C) 1986, Stanford Univ. SUMEX project.
  2121.        May be used but not sold without permission.
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128. Budne                  Expires December 31, 1993               [Page 38]
  2129.  
  2130. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  2131.  
  2132.  
  2133.    The following are trademarks;
  2134.  
  2135.        AppleTalk, EtherTalk, LaserWriter, and LocalTalk are
  2136.        trademarks of Apple Computer, Inc.
  2137.  
  2138.        FastPath is a registered trademark of Novell
  2139.        licensed for use exclusively by Shiva Corporation.
  2140.  
  2141.        K-STAR is a trademark of Novell
  2142.        licensed for use exclusively by Shiva Corporation.
  2143.  
  2144.        Kinetics is a registered trademark of Novell.
  2145.  
  2146.        Mac and Macintosh are registered trademarks of
  2147.        Apple Computer, Inc.
  2148.  
  2149.        Un*x is not a trademark of anyone.
  2150.  
  2151.  
  2152. 14.  References:
  2153.  
  2154. [RFC-768]
  2155.    Postel, J.B., ``User Datagram Protocol'', Information Sciences
  2156.    Institute, University of Southern California, August 1980.
  2157.  
  2158. [RFC-791]
  2159.    Postel, J.B., ``Internet Protocol'', Information Sciences Institute,
  2160.    University of Southern California, September 1981.
  2161.  
  2162. [RFC-826]
  2163.    Plummer, D.C.  ``Ethernet Address Resolution Protocol'', November
  2164.    1982.
  2165.  
  2166. [RFC-1060]
  2167.    Reynolds, J., and J. Postel, ``Assigned Numbers'', Information
  2168.    Sciences Institute, University of Southern California, March 1990.
  2169.  
  2170. [Sherman86]
  2171.    Sherman, M.  ``A Network Package for the Macintosh using the DoD
  2172.    Internet Protocols'', Technical Report PCS-TR86-124, Computer Network
  2173.    Laboratory, Department of Mathematics and Computer Science, Dartmouth
  2174.    College.
  2175.  
  2176. [Sidhu90]
  2177.    Sidhu, G., R. Andrews and A. Oppenheimer, ``Inside AppleTalk, Second
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184. Budne                  Expires December 31, 1993               [Page 39]
  2185.  
  2186. DRAFT                   KIP AppleTalk/IP Gateway               July 1993
  2187.  
  2188.  
  2189.    Edition'', Apple Computer, Inc.  May 1990.
  2190.  
  2191. 15.  Acknowledgments:
  2192.  
  2193.    The author is indebted to the following for their help, input and
  2194.    documentation; Scot Drysdale of Dartmouth University, Robert Elz of
  2195.    the University of Melbourne, Tom Evans of Webster Computer, David
  2196.    Hornsby of the University of Melbourne, Charlie Kim of Apple
  2197.    (formerly at Columbia University), Philip Koch of Dartmouth
  2198.    University (now at Apple Computer), Stephen Lewis (formerly of
  2199.    Kinetics), Josh Littlefield of Cayman, John Norstad of North Western
  2200.    University, Brad Parker of Cayman, Mark Sherman of Transarc (formerly
  2201.    at Dartmouth), Michael Swan of Neon Software (formerly of Kinetics),
  2202.    Dan Tappan (formerly at BB&N), and Jim Warner of UCSD.
  2203.  
  2204.    And particularly Bill Croft (now at the Institute for Global
  2205.    Communication) not only for having created SEAGate and KIP, but for
  2206.    his time spent digging up old documentation, and reviewing this
  2207.    document!
  2208.  
  2209. 16.  Author's Address:
  2210.  
  2211.     Philip Budne
  2212.     Shiva Corporation
  2213.     1 Cambridge Center
  2214.     Cambridge, MA 02142
  2215.  
  2216.     Phone:  617-252-6300
  2217.     EMail:  phil@Shiva.COM
  2218.  
  2219.  
  2220. 17.  Expiration:
  2221.  
  2222.    This draft document expires December 31, 1993.
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240. Budne                  Expires December 31, 1993               [Page 40]
  2241.  
  2242.